Imagine you're a C or C++ software application developer. You've been at this for quite a while and your job doesn't seem to be getting any easier. These past few years you've seen the growth of multiple incompatible hardware architectures, each architecture supporting multiple incompatible operating systems, and each platform operating with one or more incompatible graphical user interfaces. And now you're supposed to cope with all this and make the applications work in a distributed client-server environment. The growth of the Internet, the World-Wide Web, and "electronic commerce" have introduced new dimensions of complexity into the development process.
The tools you work with to develop applications don't appear to be helping you a whole lot. You're still coping with the same old problems, and the use of object-oriented techniques seem to have added new problems without solving the old ones. You keep saying to yourself and your friends, "There has to be a better way!"
There Has To Be A Better Way
Now there is a better way--it's the Java programming language environment from Sun Microsystems. Imagine, if you will, this development world...
ΓÇóYour programming language is object-oriented yet it's still dead simple.
ΓÇóYour development cycle is much faster because the Java language is interpreted. The old compile-link-load-test-and-crash cycle has gone the way of the zumbooruk--now you just compile and run. When you're satisfied with your application, you can obtain maximum performance by using the built in just-in-time compiler to compile the Java intermediate code to native machine code.
ΓÇóYour applications are portable across multiple platforms. Write your applications once, and you never need to port them--they will run without modification on multiple operating systems and hardware architectures.
ΓÇóYour applications are robust because the Java run-time system manages memory for you--you don't have dangling pointers and memory leaks and trashing of memory because of bad pointers, because there are no pointers.
ΓÇóYour interactive graphical applications have high performance because multiple concurrent threads of activity in your application are supported by the multithreading built into the language.
ΓÇóYour applications are dynamically adaptable to changing environments because you can dynamically load code modules from anywhere in the network.
ΓÇóYour end users can trust that your applications are secure, even though they're downloading code from all over the Internet, because the Java run-time system has built-in protection against viruses and tampering.
The Better Way Is Here
You don't need to dream about these features to make developer life easier. They're here now in the form of the Java Programming Environment, otherwise known as "the Java language"--a portable, interpreted, high performance, simple, object-oriented programming language and supporting run-time environment developed at Sun Microsystems. The rest of this introductory chapter takes a brief look at the main design goals of the Java language system. The remainder of this paper examines the features of the Java language in more detail. At the end of this paper you'll find a chapter on the HotJava browser--an innovative World-Wide web browser, a major application written using the Java language environment. The HotJava browser is unique in its ability to download and execute Java code fragments on the fly from anywhere on the Internet, and do so in a secure manner.
Beginnings of the Java Language Project
The Java language was designed to meet the challenges of application development in the context of heterogeneous network-wide distributed environments. Paramount among these challenges is the secure delivery of applications that consume the minimum of system resources, can run on any hardware and software platform, and can be dynamically extended.
The Java language originated as part of a research project to develop advanced software for a wide variety of networked devices and embedded systems. The goal was to develop a small, reliable, portable, distributed, real-time operating environment. When the project was started, C++ was the language of choice. But over time the difficulties encountered with C++ grew to the point where the problems could best be addressed by creating an entirely new language environment. Design and architecture decisions drew from a variety of languages such as Eiffel, SmallTalk, Objective C, and Cedar/Mesa. The result was a language environment that has proven ideal for development of secure, distributed, network-based end-user applications in environments ranging from networked embedded devices to the World-Wide Web and the desktop.
Design Goals of the Java Language
The design requirements of Java can be summed up as a set of characteristics--to live, to survive, and to flourish:
ΓÇóThe massive growth of the Internet and the World-Wide Web leads us to a completely new way of looking at development and distribution of software. To live in the world of electronic commerce and distribution, the Java language must support secure, high-performance, and highly robust application development on multiple platforms in heterogeneous, distributed networks.
ΓÇóOperating on multiple platforms in heterogeneous networks invalidates the traditional schemes of binary distribution, release, upgrade, patch, and so on. To survive in this jungle, the Java language must be architecture-neutral, portable, and dynamically adaptable.
ΓÇóTo ensure you can flourish within your software development environment, the Java language system that emerged to meet these needs is simple, so it can be easily programmed by most developers, familiar, so that current developers can easily learn the Java language, object oriented, to fit into distributed client-server applications, multithreaded, for high performance in applications that need to perform multiple concurrent activities, and interpreted, for maximum portability and dynamic capabilities.
All in all, the above requirements comprise quite a collection of buzzwords, so let's briefly examine some of the features and their respective benefits before getting into details in the rest of this paper.
Simple, Object Oriented, and Familiar
A primary goal of the Java language was a simple language that could be programmed without extensive programmer training and which would be roughly attuned to current software practice. The fundamental concepts of the Java language can be grasped quickly--programmers can be productive from the start.
The Java language was designed as an object-oriented language from the ground up. Object-oriented technology has finally found its way into the programming mainstream after a gestation period of thirty years. The needs of distributed, client-server based systems coincide with the packaged, message-passing paradigms of object-based software. To function within increasingly complex, network-based environments, programming systems must adopt object-oriented concepts. The Java language provides a clean and efficient object-based development environment.
Programmers starting with the Java language have access to existing libraries of tested objects that provide functionality ranging from basic data types through I/O interfaces and network interfaces to graphical user interface toolkits. Many of these libraries can be extended (subclassed) to provide new behavior.
Even though C++ was rejected as an implementation language, keeping the language familiar resulted in the Java language looking as close to C++ as possible, while removing the unnecessary complexities of C++. Making the Java language a minimal subset of C++ while simultaneously retaining its "look and feel" means that programmers can migrate to the Java language easily and be productive quickly--the Java language learning curve can be as low as a couple of days.
Robust and Secure
The Java language is designed for creating highly reliable software. Emphasis is on extensive compile-time checking, and a second level of run-time checking. Java language features guide programmers into reliable programming habits. The Java memory management model--basically, no pointers or pointer arithmetic--eliminates entire classes of programming errors that bedevil C and C++ programmers. You can develop Java code with confidence that the system will find errors quickly and that major problems won't slip out into production code.
The Java language was designed to operate in distributed environments. With security features designed into the language and run-time system, the Java language enables construction of tamper-free programs. In the networked environment, Java programs are secure from intrusion by unauthorized code attempting to get behind the scenes and create viruses or invade file systems.
Architecture Neutral and Portable
The Java language was designed to support applications operating in networked environments, operating on a variety of hardware architectures, and running a variety of operating systems and language environments. The Java language compiler generates byte codes--an architecture-neutral intermediate format used to transport code efficiently to multiple hardware and software platforms. Because of the interpreted nature of the Java language, you don't have a binary distribution and versioning problem--the same Java language byte codes will run on any platform.
Architecture neutrality is just one part of a truly portable system. The Java language takes portability a stage further by being strict in its definition of the basic language. The Java language puts a stake in the ground and specifies sizes of basic data types and the behavior of the arithmetic operators. You programs are always the same on every platform--there are no data type incompatibilities across hardware and software architectures.
The Java virtual machine is based on a well-defined porting layer, primarily based on the POSIX interface standard--an industry standard definition of a portable system interface. Porting to new architectures is a relatively straightforward task.
High Performance
Performance is always a consideration, and the Java language achieves superior performance by adopting a scheme by which the interpreter can run at full speed without needing to check the run-time environment. The automatic garbage collector runs as a low-priority background thread, ensuring a high probability that memory is available when required, leading to better performance. Applications requiring large amounts of compute power can be designed such that compute-intensive sections can be rewritten in native machine code as required and interfaced with the Java language environment. In general, users perceive that interactive applications perform adequately even though they're interpreted. When you need the full speed of the host hardware for compute-intensive applications, the Java language system provides an on-the-fly "just in time" compiler that will compile the Java language byte codes to machine code at run time. This innovative feature provides native code performance levels without compromising the portability of applications.
Interpreted, Threaded, and Dynamic
The Java interpreter can execute Java byte codes directly on any machine to which the interpreter and run-time system have been ported. In an interpreted environment such as the Java language system, the "link" phase of a program is simple, incremental, and lightweight. You gain a major benefit of much faster development cycles--prototyping, experimenting, and rapid development are the normal case.
Modern network-based applications such as the HotJava World-Wide Web browser typically need to do several things at the same time. A user operating the HotJava browser can run several animations concurrently while downloading an image and scrolling the page. The ability to perform multiple tasks concurrently is provided by the Java language's multithreading capability, which provides the means to build applications with many concurrent threads of activity. Multithreading thus results in a high degree of interactivity for the end user.
The Java language supports multithreading at the language level with the addition of sophisticated synchronization primitives, at the language library level with the Thread class, and at the run-time level with monitor and condition lock primitives. At the library level, the Java language's high-level system libraries have been written to be thread-safe--the functionality provided by the libraries is available to multiple concurrent threads of execution.
While the Java compiler is strict in its compile-time static checking, the language and run-time system are dynamic in their linking stages. Classes are linked as needed. New code modules can be linked in on demand from a variety of sources, even across a network. In the case of the HotJava web browser and similar applications, interactive executable code can be loaded from anywhere, enabling transparent updating of applications. The result is on-line services that constantly evolve, remaining innovative and fresh, drawing more customers, and spurring the growth of electronic commerce on the Internet.
The Java Environment--A New Approach to Distributed Computing
Taken individually, the characteristics discussed above can be found in a variety of software development environments. What's completely new is the manner in which the Java language and run-time system have combined them to produce an flexible and powerful programming system.
The Java language environment results in software applications that are portable, highly secure, and high performance. With the Java language to develop your software, your job as a software developer is much easier--you focus your full attention on the end goal of shipping innovative products on time, based on the solid foundation of the Java environment.